package org.jgrapht.demo;

import java.util.HashMap;
import java.util.Random;

import org.jgrapht.VertexFactory;
import org.jgrapht.generate.RandomGraphGenerator;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.SimpleWeightedGraph;

public class GeneratingRandomGraph {
static int i=0;
	public static void main(String[] args) {
		RandomGraphGenerator<String, DefaultEdge> rgg = new RandomGraphGenerator<String, DefaultEdge>(100, 150);
		
		SimpleWeightedGraph<String, DefaultEdge> rwg = new SimpleWeightedGraph<String, DefaultEdge>(DefaultEdge.class);
		
		rgg.generateGraph(rwg, new VertexFactory<String>(){

			@Override
			public String createVertex() {
				Random rand = new Random();
				Integer randInt = new Integer(rand.nextInt());
				return randInt.toString();
			}
			
		}, new HashMap<String, String>());
		
		for (String vertex : rwg.vertexSet()) {
			System.out.println(vertex);
		}
		
		for (DefaultEdge edge : rwg.edgeSet()) {
			System.out.println(rwg.getEdgeWeight(edge));
			System.out.println(edge.toString());
		}
	}

}